﻿@using BeautySalon.Models.TableModel

@model UserAdmin

@{
    ViewBag.Title = "个人信息";
    Layout = "~/Views/Shared/_LayoutOtherMaster.cshtml";
}

<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="L_UserName" class="layui-form-label">
                    <span class="x-red">*</span>登录账号
                </label>
                <div class="layui-input-inline">
                    <input type="text" readonly="readonly" id="L_UserName" name="UserName" required="" lay-verify="UserName" autocomplete="off" class="layui-input" value="@Model.UserName">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_realname" class="layui-form-label">
                    <span class="x-red">*</span>真实姓名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="L_realname" name="RealName" required="" lay-verify="NickRealName" autocomplete="off" class="layui-input" value="@Model.RealName">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_Telphone" class="layui-form-label">
                    <span class="x-red">*</span>电话
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="L_Telphone" name="Telphone" required="" lay-verify="Telphone" autocomplete="off" class="layui-input" value="@Model.Telphone">
                </div>
                <div class="layui-form-mid layui-word-aux">默认手机号是11位数字</div>
            </div>
            <div class="layui-form-item">
                <label for="L_LoginIP" class="layui-form-label">
                    <span class="x-red"></span>登录IP
                </label>
                <div class="layui-input-inline">
                    <input type="text" readonly="readonly" id="L_LoginIP" name="LoginIP" required="" autocomplete="off" class="layui-input" value="@Model.LoginIP">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_LoginTime" class="layui-form-label">
                    <span class="x-red"></span>登录时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" readonly="readonly" id="L_LoginTime" name="LoginTime" required="" autocomplete="off" class="layui-input" value="@Model.LoginTime">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_ModifyTime" class="layui-form-label">
                    <span class="x-red"></span>修改时间
                </label>
                <div class="layui-input-inline">
                    @{string sModifyTime= Model.ModifyTime.ToString()?? DateTime.Now.ToString();}
                    <input type="text" value="@sModifyTime" readonly="readonly" id="L_ModifyTime" name="ModifyTime" required="" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_Salary" class="layui-form-label">
                    <span class="x-red"></span>每月薪水
                </label>
                <div class="layui-input-inline">
                    <input type="text" readonly="readonly" id="L_Salary" name="Salary" required="" autocomplete="off" class="layui-input" value="@Model.Salary">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">修改资料</button>
                <input type="hidden" value="@Model.UserId" name="UserId" id="L_UserId"/>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'layer', 'jquery'],
        function () {
            //$ = layui.jquery;
            var form = layui.form;
            var layer = layui.layer;

            //自定义验证规则
            form.verify({
                NickRealName: function (value) {
                    if (value.length < 2) {
                        return '真实姓名至少得2个字符';
                    }
                },
                Telphone: [/^1[0123456789]\d{9}$/, '手机号码必须是11位']               
            });

            //监听提交
            form.on('submit(add)',
                function (data) {
                    layer.load(3);
                    var sFail = "";
                    $.ajax({
                        url: '/UserAdmin/UpdateAccount',
                        type: 'post',
                        data: data.field,
                        dataType: 'json',
                        success: function (data) {
                            console.log(data);
                            console.log(data.Msg);
                            console.log(data.ResultType);
                            var sMsg = data.Msg;
                            var sFail = data.Msg;
                            if (data.ResultType == 1) {
                                // 更新成功
                                layer.alert(sMsg, { icon: 6 }, function () {
                                    xadmin.close();    
                                    // 可以对父窗口进行刷新 
                                    xadmin.father_reload();
                                });
                            }
                            else{
                                // 更新失败
                                layer.alert(sMsg, { icon: 2 });
                            }
                        },
                        error: function (err) {
                            layer.alert(sFail);
                        }
                    });

                    layer.closeAll("loading");
                    return false;





                    //console.log(data);
                    ////发异步，把数据提交给php
                    //layer.alert("增加成功", {
                    //    icon: 6
                    //},
                    //    function () {
                    //        //关闭当前frame
                    //        xadmin.close();

                    //        // 可以对父窗口进行刷新
                    //        xadmin.father_reload();
                    //    });
                    //return false;
                });
        });
</script>

